/*
* 组件模块：相关攻略
* 数据：不做ssr，直接ajax获取数据
*/
import React from 'react';
import Link from 'next/link';
import { replaceImageUrl } from '@/utils';
// css
import styles from '@/styles/CommonDetail.module.scss';

class GuidePart extends React.Component {

    constructor(props) {
        super(props)
    }

    render() {
        const { title, list } = this.props;
        if (!list.length) {
            return <></>
        }
        return (
            <div className={styles['strategy-wrap']}>
                <h2>{title}</h2>
                <div className={styles['strategy-pro-list']}>
                    {
                        list.map(item => {
                            const url = `/guide/${item.id}.html`
                            return (
                                <div className={styles['item']} key={item.id}>
                                    <Link href={url}>
                                        <a className={styles['image']} target="_blank">
                                            <img src={replaceImageUrl(item.coverUrl)} alt="" />
                                        </a>
                                    </Link>
                                    <div className={styles['info']}>
                                        <h3>
                                            <Link href={url}>
                                                <a target="_blank">{item.title}</a>
                                            </Link>
                                        </h3>
                                        <p className={styles['desc']} title={item.subtitle}>{item.subtitle}</p>
                                        <p>
                                            <Link href={url}><a target="_blank">查看详情</a></Link>
                                        </p>
                                    </div>
                                </div>
                            )
                        })
                    }
                </div>
            </div>
        )
    }
}

export default GuidePart